# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libsecret
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.19.1
pkgrel=1
pkgdesc="Library for storing and retrieving passwords and other secrets (mingw-w64)"
arch=('any')
url="https://wiki.gnome.org/Projects/Libsecret"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
depends=(${MINGW_PACKAGE_PREFIX}-glib2
         ${MINGW_PACKAGE_PREFIX}-libgcrypt)
options=('!libtool' 'strip')
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz"
        "0001-port-to.mingw.patch")
sha256sums=('8583e10179456ae2c83075d95455f156dc08db6278b32bf4bd61819335a30e3a'
            '28bf8c3e22f10746177e7128e8293d2d0934f80daef37cf0e648492a07636bf8')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-port-to.mingw.patch"
  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  export MSYS2_ARG_CONV_EXCL="-//OASIS//DTD"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --enable-introspection \
    --enable-vala \
    --disable-manpages

  make
}

# some of the tests fail and hang
#check() {
#  cd "${srcdir}/build-${MINGW_CHOST}"
#  make -j1 check || true
#}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
